package xzs.wx.wxappFace.service;


import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.tencentcloudapi.common.AbstractClient;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.JsonResponseModel;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.faceid.v20180301.models.BankCard2EVerificationResponse;
import xzs.wx.wxappFace.vo.GetBizTokenRequest;
import xzs.wx.wxappFace.vo.GetInteractiveVideoResult;

import java.lang.reflect.Type;

public class GetBizTokenService extends AbstractClient {

    private static String endpoint = "faceid.tencentcloudapi.com";
    private static String version = "2018-03-01";

    public GetBizTokenService(Credential credential, String region) {
        this(credential, region, new ClientProfile());
    }

    public GetBizTokenService(Credential credential, String region, ClientProfile profile) {
        super(GetBizTokenService.endpoint, GetBizTokenService.version, credential, region, profile);
    }
    public GetBizTokenService(Credential credential,  ClientProfile profile) {
        super(GetBizTokenService.endpoint, GetBizTokenService.version, credential, null, profile);
    }

    /**
     * 本接口用于校验姓名和银行卡号的真实性和一致性。
     *
     * @param req BankCard2EVerificationRequest
     * @return BankCard2EVerificationResponse
     * @throws TencentCloudSDKException
     */
    public BankCard2EVerificationResponse getBizToken(GetBizTokenRequest req) throws TencentCloudSDKException {
        JsonResponseModel<BankCard2EVerificationResponse> rsp = null;
        try {
            Type type = new TypeToken<JsonResponseModel<BankCard2EVerificationResponse>>() {
            }.getType();
            String resp =  this.internalRequest(req, "GetBizToken");
            System.out.println(resp);
            rsp = gson.fromJson(resp, type);
        } catch (JsonSyntaxException e) {
            throw new TencentCloudSDKException(e.getMessage());
        }
        return rsp.response;
    }

    /**
     * 本接口用于校验姓名和银行卡号的真实性和一致性。
     *
     * @param req BankCard2EVerificationRequest
     * @return BankCard2EVerificationResponse
     * @throws TencentCloudSDKException
     */
    public BankCard2EVerificationResponse getInteractiveVideoResult(GetInteractiveVideoResult req) throws TencentCloudSDKException {
        JsonResponseModel<BankCard2EVerificationResponse> rsp = null;
        try {
            Type type = new TypeToken<JsonResponseModel<BankCard2EVerificationResponse>>() {
            }.getType();
            String resp =  this.internalRequest(req, "GetInteractiveVideoResult");
            System.out.println(resp);
            rsp = gson.fromJson(resp, type);
        } catch (JsonSyntaxException e) {
            throw new TencentCloudSDKException(e.getMessage());
        }
        return rsp.response;
    }

}
